package com.khiker.binary;

public class P231_IsPowerOfTwo {
	public boolean isPowerOfTwo2(int n) {
		if (n == 1) {
			return true;
		}
		if (n <= 0) {
			return false;
		}
		return (1 << 30) % n == 0;
	}

	public boolean isPowerOfTwo(int n) {
		if (n == 1) {
			return true;
		}
		if (n <= 0) {
			return false;
		}
		return (-n & n) == n;
	}

	public static void main(String[] args) {
		P231_IsPowerOfTwo solution = new P231_IsPowerOfTwo();
		System.out.println(solution.isPowerOfTwo(12));
	}
}
